<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.18"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>embedme: src/ProcUtil.h Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="logo.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">embedme
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.18 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_68267d1309a1af8e8297ef4c3efbcdba.html">src</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">ProcUtil.h</div>  </div>
</div><!--header-->
<div class="contents">
<a href="_proc_util_8h.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="comment">/******************************************************************************</span></div>
<div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="comment"> * This file is part of libemb.</span></div>
<div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="comment"> * libemb is free software: you can redistribute it and/or modify</span></div>
<div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;<span class="comment"> * it under the terms of the GNU General Public License as published by</span></div>
<div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="comment"> * the Free Software Foundation, either version 3 of the License, or</span></div>
<div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="comment"> * (at your option) any later version.</span></div>
<div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;<span class="comment"> * libemb is distributed in the hope that it will be useful,</span></div>
<div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span></div>
<div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;<span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span></div>
<div class="line"><a name="l00012"></a><span class="lineno">   12</span>&#160;<span class="comment"> * GNU General Public License for more details.</span></div>
<div class="line"><a name="l00013"></a><span class="lineno">   13</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00014"></a><span class="lineno">   14</span>&#160;<span class="comment"> * You should have received a copy of the GNU General Public License</span></div>
<div class="line"><a name="l00015"></a><span class="lineno">   15</span>&#160;<span class="comment"> * along with libemb.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span></div>
<div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="comment"> *</span></div>
<div class="line"><a name="l00017"></a><span class="lineno">   17</span>&#160;<span class="comment"> * Project: Embedme</span></div>
<div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160;<span class="comment"> * Author : FergusZeng</span></div>
<div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;<span class="comment"> * Email  : cblock@126.com</span></div>
<div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;<span class="comment"> * git    : https://gitee.com/newgolo/embedme.git</span></div>
<div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;<span class="comment"> * Copyright 2014-2020 @ ShenZhen ,China</span></div>
<div class="line"><a name="l00022"></a><span class="lineno">   22</span>&#160;<span class="comment">*******************************************************************************/</span></div>
<div class="line"><a name="l00023"></a><span class="lineno">   23</span>&#160;<span class="preprocessor">#ifndef __COMMANDPIPE_H__</span></div>
<div class="line"><a name="l00024"></a><span class="lineno">   24</span>&#160;<span class="preprocessor">#define __COMMANDPIPE_H__</span></div>
<div class="line"><a name="l00025"></a><span class="lineno">   25</span>&#160; </div>
<div class="line"><a name="l00031"></a><span class="lineno">   31</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_base_type_8h.html">BaseType.h</a>&quot;</span></div>
<div class="line"><a name="l00032"></a><span class="lineno">   32</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_i_o_device_8h.html">IODevice.h</a>&quot;</span></div>
<div class="line"><a name="l00033"></a><span class="lineno">   33</span>&#160;<span class="preprocessor">#include &quot;<a class="code" href="_str_util_8h.html">StrUtil.h</a>&quot;</span></div>
<div class="line"><a name="l00034"></a><span class="lineno">   34</span>&#160; </div>
<div class="line"><a name="l00035"></a><span class="lineno">   35</span>&#160;<span class="keyword">namespace </span>libemb{</div>
<div class="line"><a name="l00040"></a><span class="lineno"><a class="line" href="classlibemb_1_1_proc_util.html">   40</a></span>&#160;<span class="keyword">class </span><a class="code" href="classlibemb_1_1_proc_util.html">ProcUtil</a>{</div>
<div class="line"><a name="l00041"></a><span class="lineno">   41</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00042"></a><span class="lineno">   42</span>&#160;    <a class="code" href="classlibemb_1_1_proc_util.html">ProcUtil</a>(){};</div>
<div class="line"><a name="l00043"></a><span class="lineno">   43</span>&#160;    ~<a class="code" href="classlibemb_1_1_proc_util.html">ProcUtil</a>(){};</div>
<div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classlibemb_1_1_proc_util.html#a9f4ff7ca969071efc780efd6801fc492">execute</a>(std::string cmd, std::string&amp; resultStr, <span class="keywordtype">int</span> timeoutSec=-1);</div>
<div class="line"><a name="l00058"></a><span class="lineno">   58</span>&#160;    <span class="keyword">static</span> std::string <a class="code" href="classlibemb_1_1_proc_util.html#a9f4ff7ca969071efc780efd6801fc492">execute</a>(std::string cmd, <span class="keywordtype">int</span> timeoutSec=-1);</div>
<div class="line"><a name="l00067"></a><span class="lineno">   67</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">int</span> <a class="code" href="classlibemb_1_1_proc_util.html#a3c3ecd28801cdc7dff633031c1808a9c">createProc</a>(std::string procName, std::string args,std::string envs,<span class="keywordtype">int</span> delays=0);</div>
<div class="line"><a name="l00072"></a><span class="lineno">   72</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classlibemb_1_1_proc_util.html#ab9b8121401278a5a556ad6e6c4ceaa61">killProc</a>(std::string procName);</div>
<div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;    <span class="keyword">static</span> std::vector&lt;int&gt; <a class="code" href="classlibemb_1_1_proc_util.html#a386d8373b46212972b378abbf23c3baa">getPidsByName</a>(<span class="keyword">const</span> std::string&amp; processName);</div>
<div class="line"><a name="l00084"></a><span class="lineno">   84</span>&#160;    <span class="keyword">static</span> std::string <a class="code" href="classlibemb_1_1_proc_util.html#ae6d2d94ccaeb6e1a917852bab9a12ef0">getEnv</a>(<span class="keyword">const</span> std::string&amp; name);</div>
<div class="line"><a name="l00090"></a><span class="lineno">   90</span>&#160;    <span class="keyword">static</span> <span class="keywordtype">void</span> <a class="code" href="classlibemb_1_1_proc_util.html#a058a51c80f02aa4a271c7fb0d07a88b7">setEnv</a>(<span class="keyword">const</span> std::string&amp; name, <span class="keyword">const</span> std::string&amp; value);</div>
<div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;};</div>
<div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160; </div>
<div class="line"><a name="l00097"></a><span class="lineno"><a class="line" href="classlibemb_1_1_proc_fifo.html">   97</a></span>&#160;<span class="keyword">class </span><a class="code" href="classlibemb_1_1_proc_fifo.html">ProcFifo</a>:<span class="keyword">public</span> <a class="code" href="classlibemb_1_1_i_o_device.html">IODevice</a>{</div>
<div class="line"><a name="l00098"></a><span class="lineno">   98</span>&#160;<a class="code" href="_base_type_8h.html#a57e803e49526dc5ba8c1915c68708ae0">DECL_CLASSNAME</a>(<a class="code" href="classlibemb_1_1_proc_fifo.html">ProcFifo</a>)</div>
<div class="line"><a name="l00099"></a><span class="lineno">   99</span>&#160;<span class="keyword">public</span>:</div>
<div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;    <a class="code" href="classlibemb_1_1_proc_fifo.html">ProcFifo</a>();</div>
<div class="line"><a name="l00101"></a><span class="lineno">  101</span>&#160;    <span class="keyword">virtual</span> ~<a class="code" href="classlibemb_1_1_proc_fifo.html">ProcFifo</a>();</div>
<div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;    <span class="keyword">virtual</span> <span class="keywordtype">bool</span> <a class="code" href="classlibemb_1_1_proc_fifo.html#a58bad2cf8c3cabd1fd280ddc20b6979e">open</a>(<span class="keyword">const</span> <span class="keywordtype">char</span> *devName, <span class="keywordtype">int</span> ioMode = <a class="code" href="_i_o_device_8h.html#aebc0013d0befa27f40e0592cdf697438adfdb9a5b5560a6535f659200e9a1eed0">IO_MODE_RDWR_ONLY</a>); </div>
<div class="line"><a name="l00110"></a><span class="lineno">  110</span>&#160;};</div>
<div class="line"><a name="l00111"></a><span class="lineno">  111</span>&#160; </div>
<div class="line"><a name="l00112"></a><span class="lineno">  112</span>&#160;}</div>
<div class="line"><a name="l00113"></a><span class="lineno">  113</span>&#160;<span class="preprocessor">#endif</span></div>
</div><!-- fragment --></div><!-- contents -->
<div class="ttc" id="aclasslibemb_1_1_i_o_device_html"><div class="ttname"><a href="classlibemb_1_1_i_o_device.html">libemb::IODevice</a></div><div class="ttdoc">IO设备抽象类</div><div class="ttdef"><b>Definition:</b> IODevice.h:53</div></div>
<div class="ttc" id="aclasslibemb_1_1_proc_util_html_a3c3ecd28801cdc7dff633031c1808a9c"><div class="ttname"><a href="classlibemb_1_1_proc_util.html#a3c3ecd28801cdc7dff633031c1808a9c">libemb::ProcUtil::createProc</a></div><div class="ttdeci">static int createProc(std::string procName, std::string args, std::string envs, int delays=0)</div><div class="ttdoc">创建进程</div><div class="ttdef"><b>Definition:</b> ProcUtil.cpp:112</div></div>
<div class="ttc" id="aclasslibemb_1_1_proc_util_html"><div class="ttname"><a href="classlibemb_1_1_proc_util.html">libemb::ProcUtil</a></div><div class="ttdoc">进程工具类</div><div class="ttdef"><b>Definition:</b> ProcUtil.h:40</div></div>
<div class="ttc" id="a_i_o_device_8h_html"><div class="ttname"><a href="_i_o_device_8h.html">IODevice.h</a></div><div class="ttdoc">输入输出设备</div></div>
<div class="ttc" id="aclasslibemb_1_1_proc_util_html_ae6d2d94ccaeb6e1a917852bab9a12ef0"><div class="ttname"><a href="classlibemb_1_1_proc_util.html#ae6d2d94ccaeb6e1a917852bab9a12ef0">libemb::ProcUtil::getEnv</a></div><div class="ttdeci">static std::string getEnv(const std::string &amp;name)</div><div class="ttdoc">获取环境变量</div><div class="ttdef"><b>Definition:</b> ProcUtil.cpp:198</div></div>
<div class="ttc" id="a_base_type_8h_html"><div class="ttname"><a href="_base_type_8h.html">BaseType.h</a></div><div class="ttdoc">基础类型头文件</div></div>
<div class="ttc" id="a_i_o_device_8h_html_aebc0013d0befa27f40e0592cdf697438adfdb9a5b5560a6535f659200e9a1eed0"><div class="ttname"><a href="_i_o_device_8h.html#aebc0013d0befa27f40e0592cdf697438adfdb9a5b5560a6535f659200e9a1eed0">libemb::IO_MODE_RDWR_ONLY</a></div><div class="ttdeci">@ IO_MODE_RDWR_ONLY</div><div class="ttdef"><b>Definition:</b> IODevice.h:40</div></div>
<div class="ttc" id="aclasslibemb_1_1_proc_util_html_a058a51c80f02aa4a271c7fb0d07a88b7"><div class="ttname"><a href="classlibemb_1_1_proc_util.html#a058a51c80f02aa4a271c7fb0d07a88b7">libemb::ProcUtil::setEnv</a></div><div class="ttdeci">static void setEnv(const std::string &amp;name, const std::string &amp;value)</div><div class="ttdoc">设置环境变量</div><div class="ttdef"><b>Definition:</b> ProcUtil.cpp:208</div></div>
<div class="ttc" id="aclasslibemb_1_1_proc_fifo_html_a58bad2cf8c3cabd1fd280ddc20b6979e"><div class="ttname"><a href="classlibemb_1_1_proc_fifo.html#a58bad2cf8c3cabd1fd280ddc20b6979e">libemb::ProcFifo::open</a></div><div class="ttdeci">virtual bool open(const char *devName, int ioMode=IO_MODE_RDWR_ONLY)</div><div class="ttdoc">打开有名管道</div><div class="ttdef"><b>Definition:</b> ProcUtil.cpp:221</div></div>
<div class="ttc" id="aclasslibemb_1_1_proc_util_html_ab9b8121401278a5a556ad6e6c4ceaa61"><div class="ttname"><a href="classlibemb_1_1_proc_util.html#ab9b8121401278a5a556ad6e6c4ceaa61">libemb::ProcUtil::killProc</a></div><div class="ttdeci">static void killProc(std::string procName)</div><div class="ttdoc">杀死进程</div><div class="ttdef"><b>Definition:</b> ProcUtil.cpp:152</div></div>
<div class="ttc" id="aclasslibemb_1_1_proc_util_html_a9f4ff7ca969071efc780efd6801fc492"><div class="ttname"><a href="classlibemb_1_1_proc_util.html#a9f4ff7ca969071efc780efd6801fc492">libemb::ProcUtil::execute</a></div><div class="ttdeci">static int execute(std::string cmd, std::string &amp;resultStr, int timeoutSec=-1)</div><div class="ttdoc">执行命令</div><div class="ttdef"><b>Definition:</b> ProcUtil.cpp:41</div></div>
<div class="ttc" id="a_str_util_8h_html"><div class="ttname"><a href="_str_util_8h.html">StrUtil.h</a></div><div class="ttdoc">字符串工具</div></div>
<div class="ttc" id="a_base_type_8h_html_a57e803e49526dc5ba8c1915c68708ae0"><div class="ttname"><a href="_base_type_8h.html#a57e803e49526dc5ba8c1915c68708ae0">DECL_CLASSNAME</a></div><div class="ttdeci">#define DECL_CLASSNAME(ClassName)</div><div class="ttdef"><b>Definition:</b> BaseType.h:176</div></div>
<div class="ttc" id="aclasslibemb_1_1_proc_util_html_a386d8373b46212972b378abbf23c3baa"><div class="ttname"><a href="classlibemb_1_1_proc_util.html#a386d8373b46212972b378abbf23c3baa">libemb::ProcUtil::getPidsByName</a></div><div class="ttdeci">static std::vector&lt; int &gt; getPidsByName(const std::string &amp;processName)</div><div class="ttdoc">获取进程PID</div><div class="ttdef"><b>Definition:</b> ProcUtil.cpp:160</div></div>
<div class="ttc" id="aclasslibemb_1_1_proc_fifo_html"><div class="ttname"><a href="classlibemb_1_1_proc_fifo.html">libemb::ProcFifo</a></div><div class="ttdoc">进程间管道(有名管道)</div><div class="ttdef"><b>Definition:</b> ProcUtil.h:97</div></div>
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.18
</small></address>
</body>
</html>
